package com.lagou.service;


import com.alibaba.fastjson.JSONObject;

import java.io.UnsupportedEncodingException;

public class JSONSerializer implements Serializer{



    @Override
    public byte[] serialize(Object object) {

        return JSONObject.toJSONString(object).getBytes();

    }



    @Override
    public <T> T deserialize(Class<T> clazz, byte[] bytes) throws UnsupportedEncodingException {

        String str = new String(bytes,"utf-8");
        return JSONObject.parseObject(str, clazz);

    }

}
